package com.cohesion.bootstrap.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.cohesion.bootstrap.common.PublicConstants;
import com.opensymphony.xwork2.util.logging.Logger;

public class LoginFilter implements Filter {
	
	

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain filterChain) throws IOException, ServletException {
		// TODO assert whether user has logined or not.
//		System.out.println("test dofilter");
		HttpSession session = ((HttpServletRequest)request).getSession();
		if (verify(session.getAttribute(PublicConstants.USER_LOGIN_FLAG)))
		{
			//TODO verify authentication.
		};
		filterChain.doFilter(request, response);
		
	}

	private boolean verify(Object attribute) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void init(FilterConfig arg0) throws ServletException {
		// TODO Auto-generated method stub
		
	}

}
